﻿<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="ExamSubjectAdd.aspx.cs"
	Inherits="SBACN.WebSite.Admin.MemberService.Education.ExamSubjectAdd" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>内容编辑：培训管理</title>
	<link href="../../images/style.css" rel="stylesheet" type="text/css" />
	<link href="../../images/form.css" rel="stylesheet" type="text/css" />
	<link href="../../../js/ui/css/jquery.ui.all.css" rel="stylesheet" type="text/css" />
	<script src="../../../js/jquery-1.7.1.js" type="text/javascript"></script>
	<script src="../../../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script src="../../../js/ui/jquery.ui.core.js" type="text/javascript"></script>
	<script src="../../../js/ui/jquery.ui.position.js" type="text/javascript"></script>
	<script src="../../../js/ui/jquery.ui.widget.js" type="text/javascript"></script>
	<script src="../../../js/ui/jquery.ui.autocomplete.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(function () {
			//# 测试数据
			//            var availableTags = ["中国银行", "中国农业银行", "中国工商银行", "花旗银行", "中国交通银行"];
			//            $("#<%= Member.ClientID%>").autocomplete({
			//                source: availableTags
			//            });

			$("#<%= Member.ClientID%>").autocomplete({
				source: "../../../Handler/Admin/AutoCompleteMemberCompany.ashx",
				minLength: 1,
				search: function (event, ui) {
					$("#HidMemberID").val("");
				},
				select: function (event, ui) {
					//log(ui.item ? "Selected: " + ui.item.value + " aka " + ui.item.id : "Nothing selected, input was " + this.value);
					$("#HidMemberID").val(ui.item.id);
					$("#<%= Num.ClientID%>").focus();
				}
			});
		});

		function ClearMemberID() {
			$("#HidMemberID").val("");
			//alert($("#HidMemberID").val());
		}

		function CompanyAdd() {
			var separator = "-";
			var id = $("#HidMemberID").val();
			var pflag = "T";
			var name = $("#<%=Member.ClientID %>").val();

			if (name == "") {
				alert("请填选会员单位！");
				return;
			}
			if (id == "") {
				alert("请从下拉框中选择匹配的会员单位！");
				return;
			}
			var num = $("#<%=Num.ClientID %>").val();
			if (num == "") {
				alert("请填写人数！");
				return;
			}

			var str1 = "0123456789";
			var i = 0;
			for (i = 0; i < num.length; i++) {
				var onechar = num.substring(i, i + 1);
				if (i == 0 && num.length > 1 && onechar == "0") {
					alert("填写正确的人数！")
					return;
				}
				if (!(str1.indexOf(onechar) != -1)) {
					alert("请填写数字！");
					return;
				}
			}

			$("#SelCompany span").each(function () {

	
				var strthis = $(this).text();
				var pos_sep = strthis.indexOf(separator);
				var strId = strthis.substr(0, pos_sep);
				if (strId == id) {
					pflag = "F";
				}
			})

			if (pflag == "F") {
				pflag == "T";
				alert("已添加此会员单位，请删除后再执行此操作。")
				return;
			}

			var str = "<tr><td class='form-body-1' >" + name + "<span style='display:none;'>" + id + separator + num + "</span></td><td class='form-body-1' >" + num + "人</td><td><input type='button' class='btnsearch'  value='删除' onclick='DelCompany(this);' /></td></tr>";
			$("#SelCompany").prepend(str);

			//$("#HidMemberID").val("");
		}

		function DelCompany(obj) {
			$(obj).parent().parent().remove();
		}
		function CheckData(flag) {
			var subject = $("#<%= Subject.ClientID %>").val();
			if (subject == "") {
				alert("请填写考试/培训科目！");
				return false;
			}
			var start = $("#<%= StartDate.ClientID %>").val();
			if (start == "") {
				alert("请填写报名开始时间！");
				return false;
			}
			var end = $("#<%= EndDate.ClientID %>").val();
			if (end == "") {
				alert("请填写报名结束时间！");
				return false;
			}
			var date = $("#<%= ExamDate.ClientID %>").val();
			if (date == "") {
				alert("请填写考试/培训时间！");
				return false;
			}
			//# 处理会员单位
			var str = "";
			$("#SelCompany span").each(function () {
				str = str + $(this).text() + "⊙";
			})
			//alert(str);
			$("#<%= StrCompany.ClientID%>").val(str);
			return true;
		}
	</script>
</head>
<body>
	<form id="form1" runat="server">
	<center>
		<div id="contentDiv">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-stroke2">
				<tr>
					<td colspan="2" class="form-title2">
						内容编辑：培训管理
					</td>
				</tr>
				<tr>
					<td width="16%" class="form-label-1">
						<span style="color: Red">*</span>考试/培训科目：
					</td>
					<td width="84%" class="form-body-1">
						<asp:TextBox ID="Subject" runat="server" Width="98%"></asp:TextBox>
					</td>
				</tr>
				<tr>
					<td width="16%" class="form-label-1">
						<span style="color: Red">*</span>报名开始时间：
					</td>
					<td width="84%" class="form-body-1">
						<asp:TextBox ID="StartDate" runat="server" CssClass="Wdate" OnClick="WdatePicker();"></asp:TextBox>
					</td>
				</tr>
				<tr>
					<td width="16%" class="form-label-1">
						<span style="color: Red">*</span>报名结束时间：
					</td>
					<td width="84%" class="form-body-1">
						<asp:TextBox ID="EndDate" runat="server" CssClass="Wdate" OnClick="WdatePicker();"></asp:TextBox>
					</td>
				</tr>
				<tr>
					<td width="16%" class="form-label-1">
						<span style="color: Red">*</span>考试/培训时间：
					</td>
					<td width="84%" class="form-body-1">
						<asp:TextBox ID="ExamDate" runat="server" CssClass="Wdate" OnClick="WdatePicker();"></asp:TextBox>
					</td>
				</tr>
				<tr>
					<td width="16%" class="form-label-1">
						考试/培训会员单位：
					</td>
					<td width="84%" class="form-body-1">
						<input type="hidden" value="" id="HidMemberID" />
						<asp:HiddenField ID="StrCompany" runat="server" />
						<asp:TextBox ID="Member" runat="server" Width="30%"></asp:TextBox >&nbsp;&nbsp;
						<asp:TextBox ID="Num" runat="server" Width="5%"></asp:TextBox>&nbsp;&nbsp;
						<input id="MemberAdd" type="button" class="btnsearch" value="添加" onclick="CompanyAdd();" />
					</td>
				</tr>
				<tr>
					<td width="16%" class="form-label-1">
						Excel导入：
					</td>
					<td width="84%" class="form-body-1">
						<asp:LinkButton ID="lbtn_DownLoad" runat="server" onclick="lbtn_DownLoad_Click">报名限额模板下载</asp:LinkButton>&nbsp;&nbsp;
						报名限额导入:<asp:FileUpload ID="file_Excel" runat="server" /><span style="color:Red">(同时页面填写和Excel导入的情况下,如果存在冲突则以Excel为准)</span>
					</td>
				</tr>
				<tr>
					<td width="16%" class="form-label-1">
						已选会员单位：
					</td>
					<td width="84%" class="form-body-1">
						<table id="SelCompany">
							<asp:Repeater ID="CompanyList" runat="server">
								<ItemTemplate>
									<tr>
										<td class='form-body-1' >
											<%# Eval("CompanyName")%><span style='display: none;'><%# Eval("CompanyId")%>-<%# Eval("Count")%></span>
										</td>
										<td class='form-body-1' >
											<%# Eval("Count")%>人
										</td>
										<td>
											<input type='button' value='删除' class="btnsearch" onclick='DelCompany(this);' />
										</td>
									</tr>
								</ItemTemplate>
							</asp:Repeater>
						</table>
					</td>
				</tr>
				<tr>
					<td class="form-body" colspan="2">
						<asp:HiddenField ID="HidSubjectId" runat="server" Value="" />
						<asp:Button ID="Subbtn" runat="server" Text="提交" CssClass="btnsearch" OnClientClick="return CheckData(0);"
							OnClick="Subbtn_Click" />
						<asp:Button ID="EditSubbtn" runat="server" Text="提交" CssClass="btnsearch" OnClientClick=" return CheckData(1);"
							OnClick="EditSubbtn_Click" />
						<input type="button" id="CancelBtn" name="CancelBtn" class="btnsearch" value="取消"
							onclick="window.close();" />
					</td>
				</tr>
			</table>
		</div>
	</center>
	</form>
</body>
</html>
